home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / doom / quake1.zip / UHOLE.ZIP / QALL / PORTHOLE / WEAPONS.QC < prev   
Text File  |  1996-10-10  |  34KB  |  1,501 lines

  1. /*
  2. */
  3. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  4. void () player_run;
  5. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  6. void(vector org, vector vel, float damage) SpawnBlood;
  7. void() SuperDamageSound;
  8. void(entity inflictor, entity attacker, float distance, entity ignore) N_RadiusSuck;
  9. void(vector org, entity death_owner) spawn_hdeath;
  10. void(vector org) spawn_hfog;
  11. void() hdeath_touch;
  12. void() play_hole; 
  13. void() N_HoleTouch;
  14. void() N_HoleOutTouch;
  15. void() N_FireHoleOut;
  16. void() N_OutSpot;
  17. void() N_FireHole;
  18. void() Taunt;
  19.  
  20.  
  21. // called by worldspawn
  22. void() W_Precache =
  23. {
  24.         precache_sound ("weapons/taunt.wav");  // Taunt sound
  25.         precache_sound ("weapons/click5.wav"); // Hole hitting wall sound
  26.         precache_sound ("weapons/click7.wav"); // Hole teleport sound
  27.     precache_sound ("weapons/r_exp3.wav");    // new rocket explosion
  28.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  29.     precache_sound ("weapons/sgun1.wav");
  30.     precache_sound ("weapons/guncock.wav");    // player shotgun
  31.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  32.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  33.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  34.     precache_sound ("weapons/spike2.wav");    // super spikes
  35.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  36.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  37.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  38.     precache_sound ("weapons/shotgn2.wav");    // super shotgun
  39. };
  40.  
  41. float() crandom =
  42. {
  43.     return 2*(random() - 0.5);
  44. };
  45.  
  46. /*
  47. ================
  48. W_FireAxe
  49. ================
  50. */
  51. void() W_FireAxe =
  52. {
  53.     local    vector    source;
  54.     local    vector    org;
  55.  
  56.     source = self.origin + '0 0 16';
  57.     traceline (source, source + v_forward*64, FALSE, self);
  58.     if (trace_fraction == 1.0)
  59.         return;
  60.     
  61.     org = trace_endpos - v_forward*4;
  62.  
  63.     if (trace_ent.takedamage)
  64.     {
  65.         trace_ent.axhitme = 1;
  66.         SpawnBlood (org, '0 0 0', 20);
  67.         T_Damage (trace_ent, self, self, 20);
  68.     }
  69.     else
  70.     {    // hit wall
  71.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  72.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  73.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  74.         WriteCoord (MSG_BROADCAST, org_x);
  75.         WriteCoord (MSG_BROADCAST, org_y);
  76.         WriteCoord (MSG_BROADCAST, org_z);
  77.     }
  78. };
  79.  
  80.  
  81. //============================================================================
  82.  
  83.  
  84. vector() wall_velocity =
  85. {
  86.     local vector    vel;
  87.     
  88.     vel = normalize (self.velocity);
  89.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  90.     vel = vel + 2*trace_plane_normal;
  91.     vel = vel * 200;
  92.     
  93.     return vel;
  94. };
  95.  
  96.  
  97. /*
  98. ================
  99. SpawnMeatSpray
  100. ================
  101. */
  102. void(vector org, vector vel) SpawnMeatSpray =
  103. {
  104.     local    entity missile, mpuff;
  105.     local    vector    org;
  106.  
  107.     missile = spawn ();
  108.     missile.owner = self;
  109.     missile.movetype = MOVETYPE_BOUNCE;
  110.     missile.solid = SOLID_NOT;
  111.  
  112.     makevectors (self.angles);
  113.  
  114.     missile.velocity = vel;
  115.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  116.  
  117.     missile.avelocity = '3000 1000 2000';
  118.     
  119. // set missile duration
  120.     missile.nextthink = time + 1;
  121.     missile.think = SUB_Remove;
  122.  
  123.     setmodel (missile, "progs/zom_gib.mdl");
  124.     setsize (missile, '0 0 0', '0 0 0');        
  125.     setorigin (missile, org);
  126. };
  127.  
  128. /*
  129. ================
  130. SpawnBlood
  131. ================
  132. */
  133. void(vector org, vector vel, float damage) SpawnBlood =
  134. {
  135.     particle (org, vel*0.1, 73, damage*2);
  136. };
  137.  
  138. /*
  139. ================
  140. spawn_touchblood
  141. ================
  142. */
  143. void(float damage) spawn_touchblood =
  144. {
  145.     local vector    vel;
  146.  
  147.     vel = wall_velocity () * 0.2;
  148.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  149. };
  150.  
  151.  
  152. /*
  153. ================
  154. SpawnChunk
  155. ================
  156. */
  157. void(vector org, vector vel) SpawnChunk =
  158. {
  159.     particle (org, vel*0.02, 0, 10);
  160. };
  161.  
  162. /*
  163. ==============================================================================
  164.  
  165. MULTI-DAMAGE
  166.  
  167. Collects multiple small damages into a single damage
  168.  
  169. ==============================================================================
  170. */
  171.  
  172. entity    multi_ent;
  173. float    multi_damage;
  174.  
  175. void() ClearMultiDamage =
  176. {
  177.     multi_ent = world;
  178.     multi_damage = 0;
  179. };
  180.  
  181. void() ApplyMultiDamage =
  182. {
  183.     if (!multi_ent)
  184.         return;
  185.     T_Damage (multi_ent, self, self, multi_damage);
  186. };
  187.  
  188. void(entity hit, float damage) AddMultiDamage =
  189. {
  190.     if (!hit)
  191.         return;
  192.     
  193.     if (hit != multi_ent)
  194.     {
  195.         ApplyMultiDamage ();
  196.         multi_damage = damage;
  197.         multi_ent = hit;
  198.     }
  199.     else
  200.         multi_damage = multi_damage + damage;
  201. };
  202.  
  203. /*
  204. ==============================================================================
  205.  
  206. BULLETS
  207.  
  208. ==============================================================================
  209. */
  210.  
  211. /*
  212. ================
  213. TraceAttack
  214. ================
  215. */
  216. void(float damage, vector dir) TraceAttack =
  217. {
  218.     local    vector    vel, org;
  219.     
  220.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  221.     vel = vel + 2*trace_plane_normal;
  222.     vel = vel * 200;
  223.  
  224.     org = trace_endpos - dir*4;
  225.  
  226.     if (trace_ent.takedamage)
  227.     {
  228.         SpawnBlood (org, vel*0.2, damage);
  229.         AddMultiDamage (trace_ent, damage);
  230.     }
  231.     else
  232.     {
  233.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  234.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  235.         WriteCoord (MSG_BROADCAST, org_x);
  236.         WriteCoord (MSG_BROADCAST, org_y);
  237.         WriteCoord (MSG_BROADCAST, org_z);
  238.     }
  239. };
  240.  
  241. /*
  242. ================
  243. FireBullets
  244.  
  245. Used by shotgun, super shotgun, and enemy soldier firing
  246. Go to the trouble of combining multiple pellets into a single damage call.
  247. ================
  248. */
  249. void(float shotcount, vector dir, vector spread) FireBullets =
  250. {
  251.     local    vector direction;
  252.     local    vector    src;
  253.     
  254.     makevectors(self.v_angle);
  255.  
  256.     src = self.origin + v_forward*10;
  257.     src_z = self.absmin_z + self.size_z * 0.7;
  258.  
  259.     ClearMultiDamage ();
  260.     while (shotcount > 0)
  261.     {
  262.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  263.  
  264.         traceline (src, src + direction*2048, FALSE, self);
  265.         if (trace_fraction != 1.0)
  266.             TraceAttack (4, direction);
  267.  
  268.         shotcount = shotcount - 1;
  269.     }
  270.     ApplyMultiDamage ();
  271. };
  272.  
  273. /*
  274. ================
  275. W_FireShotgun
  276. ================
  277. */
  278. void() W_FireShotgun =
  279. {
  280.     local vector dir;
  281.  
  282.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);    
  283.  
  284.     self.punchangle_x = -2;
  285.     
  286.     self.currentammo = self.ammo_shells = self.ammo_shells - 1;
  287.     dir = aim (self, 100000);
  288.     FireBullets (6, dir, '0.04 0.04 0');
  289. };
  290.  
  291.  
  292. /*
  293. ================
  294. W_FireSuperShotgun
  295. ================
  296. */
  297. void() W_FireSuperShotgun =
  298. {
  299.     local vector dir;
  300.  
  301.     if (self.currentammo == 1)
  302.     {
  303.         W_FireShotgun ();
  304.         return;
  305.     }
  306.         
  307.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  308.  
  309.     self.punchangle_x = -4;
  310.     
  311.     self.currentammo = self.ammo_shells = self.ammo_shells - 2;
  312.     dir = aim (self, 100000);
  313.     FireBullets (14, dir, '0.14 0.08 0');
  314. };
  315.  
  316.  
  317. /*
  318. ==============================================================================
  319.  
  320. ROCKETS
  321.  
  322. ==============================================================================
  323. */
  324.  
  325. void()    s_explode1    =    [0,        s_explode2] {};
  326. void()    s_explode2    =    [1,        s_explode3] {};
  327. void()    s_explode3    =    [2,        s_explode4] {};
  328. void()    s_explode4    =    [3,        s_explode5] {};
  329. void()    s_explode5    =    [4,        s_explode6] {};
  330. void()    s_explode6    =    [5,        SUB_Remove] {};
  331.  
  332. void() BecomeExplosion =
  333. {
  334.     self.movetype = MOVETYPE_NONE;
  335.     self.velocity = '0 0 0';
  336.     self.touch = SUB_Null;
  337.     setmodel (self, "progs/s_explod.spr");
  338.     self.solid = SOLID_NOT;
  339.     s_explode1 ();
  340. };
  341.  
  342. void() T_MissileTouch =
  343. {
  344.     local float    damg;
  345.  
  346.     if (other == self.owner)
  347.         return;        // don't explode on owner
  348.  
  349.     if (pointcontents(self.origin) == CONTENT_SKY)
  350.     {
  351.         remove(self);
  352.         return;
  353.     }
  354.  
  355.     damg = 100 + random()*20;
  356.     
  357.     if (other.health)
  358.     {
  359.         if (other.classname == "monster_shambler")
  360.             damg = damg * 0.5;    // mostly immune
  361.         T_Damage (other, self, self.owner, damg );
  362.     }
  363.  
  364.     // don't do radius damage to the other, because all the damage
  365.     // was done in the impact
  366.     T_RadiusDamage (self, self.owner, 120, other);
  367.  
  368. //    sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  369.     self.origin = self.origin - 8*normalize(self.velocity);
  370.  
  371.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  372.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  373.     WriteCoord (MSG_BROADCAST, self.origin_x);
  374.     WriteCoord (MSG_BROADCAST, self.origin_y);
  375.     WriteCoord (MSG_BROADCAST, self.origin_z);
  376.  
  377.         BecomeExplosion ();        
  378. };
  379.  
  380.  
  381.  
  382. /*
  383. ================
  384. W_FireRocket     Nathan's dumb rocket
  385. ================
  386.  
  387. void() W_FireRocket =
  388. {
  389.         local   entity missile1, missile2, mpuff;
  390.     
  391.         self.currentammo = self.ammo_rockets = self.ammo_rockets - 2;
  392.     
  393.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  394.  
  395.     self.punchangle_x = -2;
  396.  
  397.         missile1 = spawn ();
  398.         missile2 = spawn ();
  399.         missile1.owner = self;
  400.         missile2.owner = self;
  401.         missile1.movetype = MOVETYPE_FLYMISSILE;
  402.         missile2.movetype = MOVETYPE_FLYMISSILE;
  403.         missile1.solid = SOLID_BBOX;
  404.         missile2.solid = SOLID_BBOX;
  405.  
  406. // set missile speed 
  407.  
  408.         makevectors (self.v_angle + '0 30 0');
  409.         missile1.velocity = aim(self, 1000);
  410.         missile1.velocity = missile1.velocity * 1000;
  411.         missile1.angles = vectoangles(missile1.velocity) + '0 0 30';
  412.  
  413.         makevectors (self.v_angle + '0 -30 0');
  414.         missile2.velocity = aim(self, 1000);
  415.         missile2.velocity = missile2.velocity * 1000;
  416.         missile2.angles = vectoangles(missile2.velocity) + '0 0 -30';
  417.  
  418.         missile1.touch = T_MissileTouch;
  419.         missile2.touch = T_MissileTouch;
  420.  
  421. // set missile duration
  422.  
  423.         missile1.nextthink = time + 5;
  424.         missile2.nextthink = time + 5;
  425.         missile1.think = SUB_Remove;
  426.         missile2.think = SUB_Remove;
  427.  
  428.         setmodel (missile1, "progs/missile.mdl");
  429.         setmodel (missile2, "progs/missile.mdl");
  430.         setsize (missile1, '0 0 0', '0 0 0');
  431.         setsize (missile2, '0 0 0', '0 0 0');
  432.         setorigin (missile1, self.origin + v_forward*8 + '1 0 16');
  433.         setorigin (missile2, self.origin + v_forward*8 + '-1 0 16');
  434. };
  435. */
  436.  
  437. void() W_FireRocket =
  438. {
  439.     local    entity missile, mpuff;
  440.     
  441.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  442.     
  443.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  444.  
  445.     self.punchangle_x = -2;
  446.  
  447.     missile = spawn ();
  448.     missile.owner = self;
  449.     missile.movetype = MOVETYPE_FLYMISSILE;
  450.     missile.solid = SOLID_BBOX;
  451.         
  452. // set missile speed    
  453.  
  454.     makevectors (self.v_angle);
  455.     missile.velocity = aim(self, 1000);
  456.     missile.velocity = missile.velocity * 1000;
  457.     missile.angles = vectoangles(missile.velocity);
  458.     
  459.     missile.touch = T_MissileTouch;
  460.     
  461. // set missile duration
  462.     missile.nextthink = time + 5;
  463.     missile.think = SUB_Remove;
  464.  
  465.     setmodel (missile, "progs/missile.mdl");
  466.     setsize (missile, '0 0 0', '0 0 0');        
  467.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  468. };
  469.  
  470. /*
  471. ===============================================================================
  472.  
  473. LIGHTNING
  474.  
  475. ===============================================================================
  476. */
  477.  
  478. /*
  479. =================
  480. LightningDamage
  481. =================
  482. */
  483. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  484. {
  485.     local entity        e1, e2;
  486.     local vector        f;
  487.     
  488.     f = p2 - p1;
  489.     normalize (f);
  490.     f_x = 0 - f_y;
  491.     f_y = f_x;
  492.     f_z = 0;
  493.     f = f*16;
  494.  
  495.     e1 = e2 = world;
  496.  
  497.     traceline (p1, p2, FALSE, self);
  498.     if (trace_ent.takedamage)
  499.     {
  500.         particle (trace_endpos, '0 0 100', 225, damage*4);
  501.         T_Damage (trace_ent, from, from, damage);
  502.         if (self.classname == "player")
  503.         {
  504.             if (other.classname == "player")
  505.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  506.         }
  507.     }
  508.     e1 = trace_ent;
  509.  
  510.     traceline (p1 + f, p2 + f, FALSE, self);
  511.     if (trace_ent != e1 && trace_ent.takedamage)
  512.     {
  513.         particle (trace_endpos, '0 0 100', 225, damage*4);
  514.         T_Damage (trace_ent, from, from, damage);
  515.     }
  516.     e2 = trace_ent;
  517.  
  518.     traceline (p1 - f, p2 - f, FALSE, self);
  519.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  520.     {
  521.         particle (trace_endpos, '0 0 100', 225, damage*4);
  522.         T_Damage (trace_ent, from, from, damage);
  523.     }
  524. };
  525.  
  526.  
  527. void() W_FireLightning =
  528. {
  529.     local    vector        org;
  530.  
  531.     if (self.ammo_cells < 1)
  532.     {
  533.         self.weapon = W_BestWeapon ();
  534.         W_SetCurrentAmmo ();
  535.         return;
  536.     }
  537.  
  538. // explode if under water
  539.     if (self.waterlevel > 1)
  540.     {
  541.         T_RadiusDamage (self, self, 35*self.ammo_cells, world);
  542.         self.ammo_cells = 0;
  543.         W_SetCurrentAmmo ();
  544.         return;
  545.     }
  546.  
  547.     if (self.t_width < time)
  548.     {
  549.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  550.         self.t_width = time + 0.6;
  551.     }
  552.     self.punchangle_x = -2;
  553.  
  554.     self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  555.  
  556.     org = self.origin + '0 0 16';
  557.     
  558.     traceline (org, org + v_forward*600, TRUE, self);
  559.  
  560.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  561.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  562.     WriteEntity (MSG_BROADCAST, self);
  563.     WriteCoord (MSG_BROADCAST, org_x);
  564.     WriteCoord (MSG_BROADCAST, org_y);
  565.     WriteCoord (MSG_BROADCAST, org_z);
  566.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  567.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  568.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  569.  
  570.     LightningDamage (self.origin, trace_endpos + v_forward*4, self, 30);
  571. };
  572.  
  573.  
  574. //=============================================================================
  575.  
  576.  
  577. void() GrenadeExplode =
  578. {
  579.         T_RadiusDamage (self, self.owner, 120, world);
  580.         BecomeExplosion ();
  581. };
  582.  
  583. void() Taunt =
  584. {
  585. sound (self, CHAN_WEAPON, "weapons/taunt.wav", 1, ATTN_NORM);
  586. }
  587. ;
  588.  
  589.  
  590. void() GrenadeTouch =
  591. {
  592.     if (other == self.owner)
  593.         return;        // don't explode on owner
  594.  
  595.         if (other.takedamage == DAMAGE_AIM)
  596.     {
  597.         GrenadeExplode();
  598.         return;
  599.     }
  600.  
  601.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  602.     if (self.velocity == '0 0 0')
  603.         self.avelocity = '0 0 0';
  604. };
  605.  
  606. /*
  607. ================
  608. W_FireGrenade
  609. ================
  610. */
  611. void() W_FireGrenade =
  612. {
  613.     local    entity missile, mpuff;
  614.     
  615.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  616.     
  617.         sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  618.  
  619.     self.punchangle_x = -2;
  620.  
  621.     missile = spawn ();
  622.     missile.owner = self;
  623.     missile.movetype = MOVETYPE_BOUNCE;
  624.     missile.solid = SOLID_BBOX;
  625.     missile.classname = "grenade";
  626.         
  627. // set missile speed    
  628.  
  629.     makevectors (self.v_angle);
  630.  
  631.     if (self.v_angle_x)
  632.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  633.     else
  634.     {
  635.         missile.velocity = aim(self, 10000);
  636.         missile.velocity = missile.velocity * 600;
  637.         missile.velocity_z = 200;
  638.     }
  639.  
  640.     missile.avelocity = '300 300 300';
  641.  
  642.     missile.angles = vectoangles(missile.velocity);
  643.     
  644.     missile.touch = GrenadeTouch;
  645.     
  646. // set missile duration
  647.     missile.nextthink = time + 2.5;
  648.     missile.think = GrenadeExplode;
  649.  
  650.     setmodel (missile, "progs/grenade.mdl");
  651.     setsize (missile, '0 0 0', '0 0 0');        
  652.     setorigin (missile, self.origin);
  653. };
  654.  
  655. void() N_FireHole =
  656. {
  657.         local   entity missile;
  658.  
  659.         self.currentammo = self.ammo_cells = self.ammo_cells - 1;
  660.  
  661.         missile = spawn ();
  662.         missile.owner = self;
  663.         missile.movetype = MOVETYPE_FLYMISSILE;
  664.         missile.solid = SOLID_TRIGGER;
  665.         missile.classname = "holein";
  666.         missile.target = self.netname;
  667.  
  668. // set hole speed
  669.  
  670.         makevectors (self.v_angle);
  671.         missile.velocity = aim(self, 1000);
  672.         missile.velocity = missile.velocity * 1000;
  673.         missile.angles = vectoangles(missile.velocity);
  674.         traceline (self.origin, self.origin + v_forward*1000, TRUE, self);
  675.  
  676. // what to do if it touches something
  677.         
  678.         missile.touch = N_HoleTouch;
  679.  
  680.         setmodel (missile, "progs/porthole.mdl");
  681.         setsize (missile, VEC_HULL2_MIN, VEC_HULL2_MAX);
  682.         setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  683. };
  684.  
  685. void() N_HoleTouch=
  686. {
  687.         local   string s;
  688.         local   vector direction;
  689.         local   entity t;
  690.         local   vector org;
  691.  
  692. //        sprint (self.owner, self.target);        
  693.  
  694.         if ((other.takedamage > 0) & (self.velocity != '0 0 0') & (other != self.owner))
  695.                 BecomeExplosion ();
  696.  
  697.         if ((other.takedamage > 0) & (self.velocity == '0 0 0') & (other == self.owner))
  698.         {
  699.                 t = find (world, targetname, self.target);
  700.                 if (!t)
  701.                 {
  702.                         sprint (self.owner, "\nNeed to open other end first.");
  703.                         return;
  704.                 }
  705.                 spawn_hfog (other.origin);
  706.                 makevectors (t.mangle);
  707.                 org = t.origin + 32 * v_forward;
  708.                 spawn_hfog (org);
  709.                 spawn_hdeath (t.origin, other);
  710.                 setorigin (other, t.origin);
  711.                 other.angles = t.mangle;
  712.                 other.fixangle = 1;
  713.                 other.teleport_time = time + 0.7;
  714.                 if (other.flags & FL_ONGROUND)
  715.                         other.flags = other.flags - FL_ONGROUND;
  716.                 other.velocity = v_forward * 300;
  717.                 other.flags = other.flags - other.flags & FL_ONGROUND;
  718.                 self.nextthink = time + 0.1;
  719.                 self.think = SUB_Remove;
  720.         }
  721.  
  722.         if ((other.classname == "worldspawn") & (self.velocity != '0 0 0'))
  723.         {      
  724.                 setsize (self, '0 0 0', '0 0 0');
  725.                 self.angles = vectoangles(trace_plane_normal);
  726.                 self.velocity = '0 0 0';
  727.                 self.origin = self.origin - 31*trace_plane_normal;
  728.                 sound (self, CHAN_VOICE, "weapons/click5.wav", 1, ATTN_NORM);
  729.         }
  730. };
  731.  
  732. void(vector org) spawn_hfog =
  733. {
  734.         local entity    s;
  735.  
  736.         s = spawn ();
  737.         s.origin = org;
  738.         s.nextthink = time + 0.2;
  739.         s.think = play_hole;
  740.  
  741.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  742.         WriteByte (MSG_BROADCAST, TE_TELEPORT);
  743.         WriteCoord (MSG_BROADCAST, org_x);
  744.         WriteCoord (MSG_BROADCAST, org_y);
  745.         WriteCoord (MSG_BROADCAST, org_z);
  746. };
  747.  
  748. void() play_hole =
  749. {
  750.         sound (self, CHAN_VOICE, "weapons/click7.wav", 1, ATTN_NORM);
  751.         remove (self);
  752. };
  753.  
  754. void(vector org, entity death_owner) spawn_hdeath =
  755. {
  756.         local entity    death;
  757.  
  758.         death = spawn();
  759.         death.classname = "teledeath";
  760.         death.movetype = MOVETYPE_NONE;
  761.         death.solid = SOLID_TRIGGER;
  762.         death.angles = '0 0 0';
  763.         setsize (death, death_owner.mins - '1 1 1', death_owner.maxs + '1 1 1');
  764.         setorigin (death, org);
  765.         death.touch = hdeath_touch;
  766.         death.nextthink = time + 0.2;
  767.         death.think = SUB_Remove;
  768.         death.owner = death_owner;
  769.  
  770.         force_retouch = 2;
  771. };
  772.  
  773. void() hdeath_touch =
  774. {
  775.         if (other == self.owner)
  776.                 return;
  777.  
  778.         if (other.classname == "player")
  779.         {
  780.                 if (other.invincible_finished > time)
  781.                         self.classname = "teledeath2";
  782.                 if (self.owner.classname != "player")
  783.                 {
  784.                         T_Damage (self.owner, self, self, 50000);
  785.                         return;
  786.                 }
  787.         }
  788.  
  789.         if (other.health)
  790.                 T_Damage (other, self, self, 50000);
  791. };
  792.  
  793. void() N_FireHoleOut =
  794. {
  795.     local    entity missile, mpuff;
  796.     
  797.     self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
  798.     
  799.         sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  800.  
  801.     self.punchangle_x = -2;
  802.  
  803.     missile = spawn ();
  804.     missile.owner = self;
  805.     missile.movetype = MOVETYPE_BOUNCE;
  806.     missile.solid = SOLID_BBOX;
  807.         missile.classname = "holeout";
  808.         
  809. // set missile speed    
  810.  
  811.     makevectors (self.v_angle);
  812.  
  813.     if (self.v_angle_x)
  814.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  815.     else
  816.     {
  817.         missile.velocity = aim(self, 10000);
  818.         missile.velocity = missile.velocity * 600;
  819.         missile.velocity_z = 200;
  820.     }
  821.  
  822.     missile.avelocity = '300 300 300';
  823.  
  824.     missile.angles = vectoangles(missile.velocity);
  825.     
  826.         missile.touch = N_HoleOutTouch;
  827.     
  828. // set missile duration
  829.     missile.nextthink = time + 2.5;
  830.         missile.targetname = missile.owner.netname;
  831.         missile.think = N_OutSpot;
  832.  
  833.         setmodel (missile, "progs/portball.mdl");
  834.     setsize (missile, '0 0 0', '0 0 0');        
  835.     setorigin (missile, self.origin);
  836. };
  837.  
  838. void() N_HoleOutTouch =
  839. {
  840.         sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);  // bounce sound
  841. };
  842.  
  843. void() N_OutSpot =
  844. {
  845.         self.origin = self.origin + '0 50 0';
  846.         // Remove it from the game.
  847.         self.movetype = MOVETYPE_NONE;
  848.         self.velocity = '0 0 0';
  849.         self.touch = SUB_Null;
  850.         self.solid = SOLID_NOT;
  851.  
  852.         self.angles = '0 0 0';
  853.         self.model = "";
  854.         self.origin = self.origin + '0 0 27';
  855. //        self.targetname = self.owner.netname;
  856. };
  857.  
  858.  
  859. //=============================================================================
  860.  
  861. void() spike_touch;
  862. void() superspike_touch;
  863.  
  864.  
  865. /*
  866. ===============
  867. launch_spike
  868.  
  869. Used for both the player and the ogre
  870. ===============
  871. */
  872. void(vector org, vector dir) launch_spike =
  873. {
  874.     newmis = spawn ();
  875.     newmis.owner = self;
  876.     newmis.movetype = MOVETYPE_FLYMISSILE;
  877.     newmis.solid = SOLID_BBOX;
  878.  
  879.     newmis.angles = vectoangles(dir);
  880.     
  881.     newmis.touch = spike_touch;
  882.     newmis.classname = "spike";
  883.     newmis.think = SUB_Remove;
  884.     newmis.nextthink = time + 6;
  885.         setmodel (newmis, "progs/spike.mdl");
  886.  
  887.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
  888.     setorigin (newmis, org);
  889.  
  890.     newmis.velocity = dir * 1000;
  891. };
  892.  
  893. void() W_FireSuperSpikes =
  894. {
  895.     local vector    dir;
  896.     local entity    old;
  897.     
  898.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  899.     self.attack_finished = time + 0.2;
  900.     self.currentammo = self.ammo_nails = self.ammo_nails - 2;
  901.     dir = aim (self, 1000);
  902.     launch_spike (self.origin + '0 0 16', dir);
  903.     newmis.touch = superspike_touch;
  904.         setmodel (newmis, "progs/s_spike.mdl");
  905.  
  906.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  907.     self.punchangle_x = -2;
  908. };
  909.  
  910. void(float ox) W_FireSpikes =
  911. {
  912.     local vector    dir;
  913.     local entity    old;
  914.     
  915.     makevectors (self.v_angle);
  916.     
  917.     if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
  918.     {
  919.         W_FireSuperSpikes ();
  920.         return;
  921.     }
  922.  
  923.     if (self.ammo_nails < 1)
  924.     {
  925.         self.weapon = W_BestWeapon ();
  926.         W_SetCurrentAmmo ();
  927.         return;
  928.     }
  929.  
  930.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  931.     self.attack_finished = time + 0.2;
  932.     self.currentammo = self.ammo_nails = self.ammo_nails - 1;
  933.     dir = aim (self, 1000);
  934.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  935.  
  936.     self.punchangle_x = -2;
  937. };
  938.  
  939.  
  940.  
  941. .float hit_z;
  942. void() spike_touch =
  943. {
  944. local float rand;
  945.     if (other == self.owner)
  946.         return;
  947.  
  948.     if (other.solid == SOLID_TRIGGER)
  949.         return;    // trigger field, do nothing
  950.  
  951.     if (pointcontents(self.origin) == CONTENT_SKY)
  952.     {
  953.         remove(self);
  954.         return;
  955.     }
  956.     
  957. // hit something that bleeds
  958.     if (other.takedamage)
  959.     {
  960.         spawn_touchblood (9);
  961.         T_Damage (other, self, self.owner, 9);
  962.     }
  963.     else
  964.     {
  965.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  966.         
  967.         if (self.classname == "wizspike")
  968.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  969.         else if (self.classname == "knightspike")
  970.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  971.         else
  972.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  973.         WriteCoord (MSG_BROADCAST, self.origin_x);
  974.         WriteCoord (MSG_BROADCAST, self.origin_y);
  975.         WriteCoord (MSG_BROADCAST, self.origin_z);
  976.     }
  977.  
  978.     remove(self);
  979.  
  980. };
  981.  
  982. void() superspike_touch =
  983. {
  984. local float rand;
  985.     if (other == self.owner)
  986.         return;
  987.  
  988.     if (other.solid == SOLID_TRIGGER)
  989.         return;    // trigger field, do nothing
  990.  
  991.     if (pointcontents(self.origin) == CONTENT_SKY)
  992.     {
  993.         remove(self);
  994.         return;
  995.     }
  996.     
  997. // hit something that bleeds
  998.     if (other.takedamage)
  999.     {
  1000.         spawn_touchblood (18);
  1001.         T_Damage (other, self, self.owner, 18);
  1002.     }
  1003.     else
  1004.     {
  1005.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  1006.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  1007.         WriteCoord (MSG_BROADCAST, self.origin_x);
  1008.         WriteCoord (MSG_BROADCAST, self.origin_y);
  1009.         WriteCoord (MSG_BROADCAST, self.origin_z);
  1010.     }
  1011.  
  1012.     remove(self);
  1013.  
  1014. };
  1015.  
  1016.  
  1017. /*
  1018. ===============================================================================
  1019.  
  1020. PLAYER WEAPON USE
  1021.  
  1022. ===============================================================================
  1023. */
  1024.  
  1025. void() W_SetCurrentAmmo =
  1026. {
  1027.     player_run ();        // get out of any weapon firing states
  1028.  
  1029.     self.items = self.items - ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS) );
  1030.     
  1031.     if (self.weapon == IT_AXE)
  1032.     {
  1033.         self.currentammo = 0;
  1034.         self.weaponmodel = "progs/v_axe.mdl";
  1035.         self.weaponframe = 0;
  1036.     }
  1037.     else if (self.weapon == IT_SHOTGUN)
  1038.     {
  1039.         self.currentammo = self.ammo_shells;
  1040.         self.weaponmodel = "progs/v_shot.mdl";
  1041.         self.weaponframe = 0;
  1042.         self.items = self.items | IT_SHELLS;
  1043.     }
  1044.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1045.     {
  1046.         self.currentammo = self.ammo_shells;
  1047.         self.weaponmodel = "progs/v_shot2.mdl";
  1048.         self.weaponframe = 0;
  1049.         self.items = self.items | IT_SHELLS;
  1050.     }
  1051.     else if (self.weapon == IT_NAILGUN)
  1052.     {
  1053.         self.currentammo = self.ammo_nails;
  1054.         self.weaponmodel = "progs/v_nail.mdl";
  1055.         self.weaponframe = 0;
  1056.         self.items = self.items | IT_NAILS;
  1057.     }
  1058.     else if (self.weapon == IT_SUPER_NAILGUN)
  1059.     {
  1060.         self.currentammo = self.ammo_nails;
  1061.         self.weaponmodel = "progs/v_nail2.mdl";
  1062.         self.weaponframe = 0;
  1063.         self.items = self.items | IT_NAILS;
  1064.     }
  1065.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1066.     {
  1067.         self.currentammo = self.ammo_rockets;
  1068.         self.weaponmodel = "progs/v_rock.mdl";
  1069.         self.weaponframe = 0;
  1070.         self.items = self.items | IT_ROCKETS;
  1071.     }
  1072.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1073.     {
  1074.         self.currentammo = self.ammo_rockets;
  1075.         self.weaponmodel = "progs/v_rock2.mdl";
  1076.         self.weaponframe = 0;
  1077.         self.items = self.items | IT_ROCKETS;
  1078.     }
  1079.     else if (self.weapon == IT_LIGHTNING)
  1080.     {
  1081.         self.currentammo = self.ammo_cells;
  1082.         self.weaponmodel = "progs/v_light.mdl";
  1083.         self.weaponframe = 0;
  1084.         self.items = self.items | IT_CELLS;
  1085.     }
  1086.     else
  1087.     {
  1088.         self.currentammo = 0;
  1089.         self.weaponmodel = "";
  1090.         self.weaponframe = 0;
  1091.     }
  1092. };
  1093.  
  1094. float() W_BestWeapon =
  1095. {
  1096.     local    float    it;
  1097.     
  1098.     it = self.items;
  1099.  
  1100.     if(self.ammo_cells >= 1 && (it & IT_LIGHTNING) )
  1101.         return IT_LIGHTNING;
  1102.     else if(self.ammo_nails >= 2 && (it & IT_SUPER_NAILGUN) )
  1103.         return IT_SUPER_NAILGUN;
  1104.     else if(self.ammo_shells >= 2 && (it & IT_SUPER_SHOTGUN) )
  1105.         return IT_SUPER_SHOTGUN;
  1106.     else if(self.ammo_nails >= 1 && (it & IT_NAILGUN) )
  1107.         return IT_NAILGUN;
  1108.     else if(self.ammo_shells >= 1 && (it & IT_SHOTGUN) )
  1109.         return IT_SHOTGUN;
  1110.         
  1111. /*
  1112.     if(self.ammo_rockets >= 1 && (it & IT_ROCKET_LAUNCHER) )
  1113.         return IT_ROCKET_LAUNCHER;
  1114.     else if(self.ammo_rockets >= 1 && (it & IT_GRENADE_LAUNCHER) )
  1115.         return IT_GRENADE_LAUNCHER;
  1116.  
  1117. */
  1118.  
  1119.     return IT_AXE;
  1120. };
  1121.  
  1122. float() W_CheckNoAmmo =
  1123. {
  1124.     if (self.currentammo > 0)
  1125.         return TRUE;
  1126.  
  1127.     if (self.weapon == IT_AXE)
  1128.         return TRUE;
  1129.     
  1130.     self.weapon = W_BestWeapon ();
  1131.  
  1132.     W_SetCurrentAmmo ();
  1133.     
  1134. // drop the weapon down
  1135.     return FALSE;
  1136. };
  1137.  
  1138. /*
  1139. ============
  1140. W_Attack
  1141.  
  1142. An attack impulse can be triggered now
  1143. ============
  1144. */
  1145. void()    player_axe1;
  1146. void()    player_axeb1;
  1147. void()    player_axec1;
  1148. void()    player_axed1;
  1149. void()    player_shot1;
  1150. void()    player_nail1;
  1151. void()    player_light1;
  1152. void()    player_rocket1;
  1153.  
  1154. void() W_Attack =
  1155. {
  1156.     local    float    r;
  1157.  
  1158.     if (!W_CheckNoAmmo ())
  1159.         return;
  1160.  
  1161.     makevectors    (self.v_angle);            // calculate forward angle for velocity
  1162.     self.show_hostile = time + 1;    // wake monsters up
  1163.  
  1164.     if (self.weapon == IT_AXE)
  1165.     {
  1166.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1167.         r = random();
  1168.         if (r < 0.25)
  1169.             player_axe1 ();
  1170.         else if (r<0.5)
  1171.             player_axeb1 ();
  1172.         else if (r<0.75)
  1173.             player_axec1 ();
  1174.         else
  1175.             player_axed1 ();
  1176.         self.attack_finished = time + 0.5;
  1177.     }
  1178.     else if (self.weapon == IT_SHOTGUN)
  1179.     {
  1180.         player_shot1 ();
  1181.         W_FireShotgun ();
  1182.         self.attack_finished = time + 0.5;
  1183.     }
  1184.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1185.     {
  1186.         player_shot1 ();
  1187.         W_FireSuperShotgun ();
  1188.         self.attack_finished = time + 0.7;
  1189.     }
  1190.     else if (self.weapon == IT_NAILGUN)
  1191.     {
  1192.         player_nail1 ();
  1193.     }
  1194.     else if (self.weapon == IT_SUPER_NAILGUN)
  1195.     {
  1196.         player_nail1 ();
  1197.     }
  1198.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1199.     {
  1200.         player_rocket1();
  1201.         W_FireGrenade();
  1202.         self.attack_finished = time + 0.6;
  1203.     }
  1204.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1205.     {
  1206.         player_rocket1();
  1207.         W_FireRocket();
  1208.         self.attack_finished = time + 0.8;
  1209.     }
  1210.     else if (self.weapon == IT_LIGHTNING)
  1211.     {
  1212.         player_light1();
  1213.         self.attack_finished = time + 0.1;
  1214.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1215.     }
  1216. };
  1217.  
  1218. /*
  1219. ============
  1220. W_ChangeWeapon
  1221.  
  1222. ============
  1223. */
  1224. void() W_ChangeWeapon =
  1225. {
  1226.     local    float    it, am, fl;
  1227.     
  1228.     it = self.items;
  1229.     am = 0;
  1230.     
  1231.     if (self.impulse == 1)
  1232.     {
  1233.         fl = IT_AXE;
  1234.     }
  1235.     else if (self.impulse == 2)
  1236.     {
  1237.         fl = IT_SHOTGUN;
  1238.         if (self.ammo_shells < 1)
  1239.             am = 1;
  1240.     }
  1241.     else if (self.impulse == 3)
  1242.     {
  1243.         fl = IT_SUPER_SHOTGUN;
  1244.         if (self.ammo_shells < 2)
  1245.             am = 1;
  1246.     }        
  1247.     else if (self.impulse == 4)
  1248.     {
  1249.         fl = IT_NAILGUN;
  1250.         if (self.ammo_nails < 1)
  1251.             am = 1;
  1252.     }
  1253.     else if (self.impulse == 5)
  1254.     {
  1255.         fl = IT_SUPER_NAILGUN;
  1256.         if (self.ammo_nails < 2)
  1257.             am = 1;
  1258.     }
  1259.     else if (self.impulse == 6)
  1260.     {
  1261.         fl = IT_GRENADE_LAUNCHER;
  1262.         if (self.ammo_rockets < 1)
  1263.             am = 1;
  1264.     }
  1265.     else if (self.impulse == 7)
  1266.     {
  1267.         fl = IT_ROCKET_LAUNCHER;
  1268.         if (self.ammo_rockets < 1)
  1269.             am = 1;
  1270.     }
  1271.     else if (self.impulse == 8)
  1272.     {
  1273.         fl = IT_LIGHTNING;
  1274.         if (self.ammo_cells < 1)
  1275.             am = 1;
  1276.     }
  1277.  
  1278.     self.impulse = 0;
  1279.     
  1280.     if (!(self.items & fl))
  1281.     {    // don't have the weapon or the ammo
  1282.         sprint (self, "no weapon.\n");
  1283.         return;
  1284.     }
  1285.     
  1286.     if (am)
  1287.     {    // don't have the ammo
  1288.         sprint (self, "not enough ammo.\n");
  1289.         return;
  1290.     }
  1291.  
  1292. //
  1293. // set weapon, set ammo
  1294. //
  1295.     self.weapon = fl;        
  1296.     W_SetCurrentAmmo ();
  1297. };
  1298.  
  1299. /*
  1300. ============
  1301. CheatCommand
  1302. ============
  1303. */
  1304. void() CheatCommand =
  1305. {
  1306.     if (deathmatch || coop)
  1307.         return;
  1308.  
  1309.     self.ammo_rockets = 100;
  1310.     self.ammo_nails = 200;
  1311.     self.ammo_shells = 100;
  1312.     self.items = self.items | 
  1313.         IT_AXE |
  1314.         IT_SHOTGUN |
  1315.         IT_SUPER_SHOTGUN |
  1316.         IT_NAILGUN |
  1317.         IT_SUPER_NAILGUN |
  1318.         IT_GRENADE_LAUNCHER |
  1319.         IT_ROCKET_LAUNCHER |
  1320.         IT_KEY1 | IT_KEY2;
  1321.  
  1322.     self.ammo_cells = 200;
  1323.     self.items = self.items | IT_LIGHTNING;
  1324.  
  1325.     self.weapon = IT_ROCKET_LAUNCHER;
  1326.     self.impulse = 0;
  1327.     W_SetCurrentAmmo ();
  1328. };
  1329.  
  1330. /*
  1331. ============
  1332. CycleWeaponCommand
  1333.  
  1334. Go to the next weapon with ammo
  1335. ============
  1336. */
  1337. void() CycleWeaponCommand =
  1338. {
  1339.     local    float    it, am;
  1340.     
  1341.     it = self.items;
  1342.     self.impulse = 0;
  1343.     
  1344.     while (1)
  1345.     {
  1346.         am = 0;
  1347.  
  1348.         if (self.weapon == IT_LIGHTNING)
  1349.         {
  1350.             self.weapon = IT_AXE;
  1351.         }
  1352.         else if (self.weapon == IT_AXE)
  1353.         {
  1354.             self.weapon = IT_SHOTGUN;
  1355.             if (self.ammo_shells < 1)
  1356.                 am = 1;
  1357.         }
  1358.         else if (self.weapon == IT_SHOTGUN)
  1359.         {
  1360.             self.weapon = IT_SUPER_SHOTGUN;
  1361.             if (self.ammo_shells < 2)
  1362.                 am = 1;
  1363.         }        
  1364.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1365.         {
  1366.             self.weapon = IT_NAILGUN;
  1367.             if (self.ammo_nails < 1)
  1368.                 am = 1;
  1369.         }
  1370.         else if (self.weapon == IT_NAILGUN)
  1371.         {
  1372.             self.weapon = IT_SUPER_NAILGUN;
  1373.             if (self.ammo_nails < 2)
  1374.                 am = 1;
  1375.         }
  1376.         else if (self.weapon == IT_SUPER_NAILGUN)
  1377.         {
  1378.             self.weapon = IT_GRENADE_LAUNCHER;
  1379.             if (self.ammo_rockets < 1)
  1380.                 am = 1;
  1381.         }
  1382.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1383.         {
  1384.             self.weapon = IT_ROCKET_LAUNCHER;
  1385.             if (self.ammo_rockets < 1)
  1386.                 am = 1;
  1387.         }
  1388.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1389.         {
  1390.             self.weapon = IT_LIGHTNING;
  1391.             if (self.ammo_cells < 1)
  1392.                 am = 1;
  1393.         }
  1394.     
  1395.         if ( (self.items & self.weapon) && am == 0)
  1396.         {
  1397.             W_SetCurrentAmmo ();
  1398.             return;
  1399.         }
  1400.     }
  1401.  
  1402. };
  1403.  
  1404. /*
  1405. ============
  1406. ServerflagsCommand
  1407.  
  1408. Just for development
  1409. ============
  1410. */
  1411. void() ServerflagsCommand =
  1412. {
  1413.     serverflags = serverflags * 2 + 1;
  1414. };
  1415.  
  1416. void() QuadCheat =
  1417. {
  1418.     if (deathmatch || coop)
  1419.         return;
  1420.     self.super_time = 1;
  1421.     self.super_damage_finished = time + 30;
  1422.     self.items = self.items | IT_QUAD;
  1423.     dprint ("quad cheat\n");
  1424. };
  1425.  
  1426. /*
  1427. ============
  1428. ImpulseCommands
  1429.  
  1430. ============
  1431. */
  1432. void() ImpulseCommands =
  1433. {
  1434.     if (self.impulse >= 1 && self.impulse <= 8)
  1435.         W_ChangeWeapon ();
  1436.  
  1437.     if (self.impulse == 9)
  1438.         CheatCommand ();
  1439.     if (self.impulse == 10)
  1440.         CycleWeaponCommand ();
  1441.     if (self.impulse == 11)
  1442.         ServerflagsCommand ();
  1443.  
  1444.         if (self.impulse == 100)
  1445.                 N_FireHoleOut ();
  1446.         if (self.impulse == 101)
  1447.                 N_FireHole ();
  1448.         if (self.impulse == 102)
  1449.                 Taunt ();
  1450.  
  1451.  
  1452.     if (self.impulse == 255)
  1453.         QuadCheat ();
  1454.         
  1455.     self.impulse = 0;
  1456. };
  1457.  
  1458. /*
  1459. ============
  1460. W_WeaponFrame
  1461.  
  1462. Called every frame so impulse events can be handled as well as possible
  1463. ============
  1464. */
  1465. void() W_WeaponFrame =
  1466. {
  1467.     if (time < self.attack_finished)
  1468.         return;
  1469.  
  1470.     ImpulseCommands ();
  1471.     
  1472. // check for attack
  1473.     if (self.button0)
  1474.     {
  1475.         SuperDamageSound ();
  1476.         W_Attack ();
  1477.     }
  1478. };
  1479.  
  1480. /*
  1481. ========
  1482. SuperDamageSound
  1483.  
  1484. Plays sound if needed
  1485. ========
  1486. */
  1487. void() SuperDamageSound =
  1488. {
  1489.     if (self.super_damage_finished > time)
  1490.     {
  1491.         if (self.super_sound < time)
  1492.         {
  1493.             self.super_sound = time + 1;
  1494.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1495.         }
  1496.     }
  1497.     return;
  1498. };
  1499.  
  1500.  
  1501.